package upload;

import java.io.FileOutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
import java.net.Socket;

public class ServerThread implements Runnable{
    private Socket socket;

    public ServerThread(Socket socket) {
        this.socket = socket;
    }

    public ServerThread() {
    }

    @Override
    public void run() {
        try {
            InputStream is = socket.getInputStream();
            OutputStream os = new FileOutputStream("/Users/edy/Desktop/file/"+System.currentTimeMillis()+".txt");
            int len;
            byte[] bytes = new byte[1024];
            while ((len = is.read(bytes)) > 0 ) {
                os.write(bytes,0,len);
            }
        } catch (IOException e) {
            e.printStackTrace();
        }
    }
}
